package com.hmall.trade.Listener;


import com.hmall.trade.service.IOrderService;
import lombok.RequiredArgsConstructor;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
public class PayStatusListener {
    private final IOrderService orderService;
    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name="trade.pay.success",durable = "true"),
            exchange=@Exchange(name ="pay.direct"),
            key={"pay.success"}
    ))
    void listenPayStatus(Long orderId){
        orderService.markOrderPaySuccess(orderId);
    }
}
